#ifndef _PRINT_LOG_H_
#define _PRINT_LOG_H_ 

//NOTE:
//__FUNCTION__ is treated by ISO C
//__FUNC__ is treated by C99
//
//gcc's pre-treatment
//#define LOGS(format, args...)printf("%s(L%d) "format" \n", __FUNCTION__, __LINE__, ##args);
//#define LOGV(x, format) printf("%s(L%d)" #x" = "format" \n" , __FUNCTION__, __LINE__, x);
//
//C99's pre-treatment
//#define LOGS(fmt, ...) printk("%s: %s(L%d) " fmt " \n", __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
//#define LOGV(x, fmt) printk("%s: %s(L%d) " #x " = " #fmt "\n", __FILE__, __FUNCTION__,  __LINE__, x)
//
//how to use it.
//int main()
//{
//	char str[10]="jerry";
//	int i = 6;
//
//	LOGS("My name is %s, %s", str, "HAHA!");	
//	LOGV(i, "%d");
//}

#define JDBG_LEVEL KERN_ERR

#undef JDBG		//avoid redefinition
#ifdef J_DEBUG
#	ifdef __KERNEL__	/*For kernel space*/
#	define JDBG(fmt, args...)	printk(	JDBG_LEVEL "JDBG: %s_%s(L%d)	" fmt " \n ",__FILE__, __FUNCTION__, __LINE__,  ##args)
#	else	/*For user space*/
#	define JDBG(fmt, args...)	fprintf(stderr, "JDBG: %s_%s(L%d)	" fmt " \n", __FILE__, __FUNCTION__, __LINE__, ##args)
#	endif
#else
#	define JDBG(fmt, args...)
#endif

/*-------------------------------------------------------------------------------*/
/*FOR EXAMPLE*/
#if 0 
#include <stdio.h>

#define JDBG_LEVEL KERN_ERR

#undef JDBG		//avoid redefinition
#ifdef J_DEBUG
#	ifdef __KERNEL__	/*For kernel space*/
#	define JDBG(fmt, args...)	printk(	JDBG_LEVEL "JDBG: %s_%s(L%d)	" fmt " \n ",__FILE__, __FUNCTION__, __LINE__,  ##args)
#	else	/*For user space*/
#	define JDBG(fmt, args...)	fprintf(stderr, "JDBG: %s_%s(L%d)	" fmt " \n", __FILE__, __FUNCTION__, __LINE__, ##args)
#	endif
#else
#	define JDBG(fmt, args...)
#endif

int main()
{
	char str[10]="jerry";
	int i = 6;

	JDBG("My name is %s, %s", str, "HAHA!");	
}
#endif
/*-------------------------------------------------------------------------------*/

#define SLEEP5 LOGS("sleep 5s ........................................................");	\
					msleep(5000);
